<%
'生成组件
'read utf8/gb2312 file
Private Function NewRead(FileUrl, Charset)
	If "gb2312" <> Charset Then Charset = "utf-8"
	Dim stm
	Set stm = Server.CreateObject("ADODB.Stream")
	With stm
		.Type = 2
		.Mode = 3
		.Open
		.LoadFromFile FileUrl
		.Charset = Charset
		.Position = 2
		NewRead = .ReadText
		.Close
	End With
	Set stm = Nothing
End Function
'write utf-8/gb2312 file
Private Function Write2File(FileUrl, tmpStr, Charset)
	If "gb2312" <> Charset Then Charset = "utf-8"
	Dim stm, errStr
	errStr = "OK"
	Set stm = Server.CreateObject("ADODB.Stream")
	With stm
		.Type = 2
		.Mode = 3
		.Charset = Charset
		.Open
		.WriteText tmpStr
		.SaveToFile FileUrl, 2
		.Flush
		.Close
	End With
	Set stm = Nothing
End Function

Function HTMLDecode(reString)
	Dim Str:Str=reString
	If Not IsNull(Str) Then
		Str = Replace(Str, "&amp;", "&")
		Str = Replace(Str, "&gt;", ">")
		Str = Replace(Str, "&lt;", "<")
		Str = Replace(Str, "&nbsp;", CHR(32))
	    Str = Replace(Str, "&nbsp;", CHR(9))
		Str = Replace(Str, "&#160;&#160;&#160;&#160;", CHR(9))
		Str = Replace(Str, "&quot;", CHR(34))
		Str = Replace(Str, "&#39;", CHR(39))
		Str = Replace(Str, "", CHR(13))
		Str = Replace(Str, "<br />", CHR(10))
		HTMLDecode = Str
	End If
End Function

Function ClearHTML(strHTML) 
	Dim objRegExp, Match, Matches 
	Set objRegExp = New Regexp 
	objRegExp.IgnoreCase = True 
	objRegExp.Global = True 
	objRegExp.Pattern = "<.+?>" 
	Set Matches = objRegExp.Execute(strHTML) 
	For Each Match in Matches 
		strHtml=Replace(strHTML,Match.Value,"")
	Next 
	ClearHTML=strHTML 
	Set objRegExp = Nothing 
End Function

Function CheckStr(str) 
    CheckStr=replace(replace(replace(str,"<","&lt;"),">","&gt;"),chr(13),"<br />") 
   CheckStr=replace(replace(replace(replace(replace(CheckStr,"'",""),"and",""),"insert",""),"set",""),"or","") 
    CheckStr=replace(replace(replace(replace(CheckStr,"select",""),"update",""),"delete%20from",""),chr(34),"&quot;") 
End Function

Function LeftStr(byVal Str,byVal StrLen)
    Dim l,t,c,i
    l=Len(str)
    t=0
    For i=1 To l
        c=AscW(Mid(str,i,1))
        If c<0 Or c>255 Then t=t+2 Else t=t+1
        IF t>=StrLen Then
            LeftStr=left(Str,i)&".."
            Exit For
        Else
            LeftStr=Str
        End If
    Next
End Function

Function IsK(str)
	If Len(str)=0 Or str="" Or IsNull(str) Then
		isK = True
	Else
		isK = False
	End if
End Function

Function IsValidEmail(email)
    Dim names, name, i, c
    IsValidEmail = True
    names = Split(email, "@")
    If UBound(names) <> 1 Then
       IsValidEmail = False
       Exit Function
    End If
    For Each name In names
        If Len(name) <= 0 Then
        IsValidEmail = False
        Exit Function
        End If
        For i = 1 To Len(name)
        c = LCase(Mid(name, i, 1))
        If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then
           IsValidEmail = False
           Exit Function
         End If
       Next
       If Left(name, 1) = "." Or Right(name, 1) = "." Then
          IsValidEmail = False
          Exit Function
       End If
    Next
    If InStr(names(1), ".") <= 0 Then
        IsValidEmail = False
       Exit Function
    End If
    i = Len(names(1)) - InStrRev(names(1), ".")
    If i <> 2 And i <> 3 And i <> 4 Then
       IsValidEmail = False
       Exit Function
    End If
    If InStr(email, "..") > 0 Then
       IsValidEmail = False
    End If
End Function

Sub ShowMsg(str,action)
	Response.Write "<script type='text/javascript'>alert('"&str&"');</script>"
	If action="back" Then
		Response.Write "<script type='text/javascript'>history.back();</script>"
	ElseIf action="go" Then
		Response.Write "<script type='text/javascript'>history.go(-1);</script>"
	Else
		Response.Write "<script type='text/javascript'>location.href='"&action&"';</script>"
	End If
	Response.End
End Sub

Function getClass(id)
	sqlc = "select id,classname from [class]"
	set rs = server.CreateObject("adodb.recordset")
	rs.open sqlc,conn,1,1
	if not (rs.eof and rs.bof) then
		do while not rs.eof
			strc = strc & "<li"
			if rs("id") = id then
				strc = strc & " class=""tabon"""
			end if
			strc = strc &"><a href="""&sitepath&"class/?cid="&rs("id")&""">"&rs("classname")&"</a></li>"
			rs.movenext
		loop
	end if
	rs.close
	set rs = nothing
	getClass = strc
End Function
Function getArea(id,path)
	sqla = "select id,area from area"
	set rs = server.CreateObject("adodb.recordset")
	rs.open sqla,conn,1,1
	if not (rs.eof and rs.bof) then
		do while not rs.eof
			stra = stra & "<a"
			if rs("id") = id then
				stra = stra & " class=""in"""
			end if
			if path = "" then
				stra = stra &" href="""&sitepath&"class/?aid="&rs("id")&""">"&rs("area")&"</a>&nbsp;&nbsp;"
			else
				stra = stra &" href="""&sitepath&"class/?"&path&"&aid="&rs("id")&""">"&rs("area")&"</a>&nbsp;&nbsp;"
			end if
			rs.movenext
		loop
	end if
	rs.close
	set rs = nothing
	getArea = stra
End Function
Function getClassName(id)
	sqlcn = "select classname from class where id = "&id
	set rscn = conn.execute(sqlcn)
	if not (rscn.eof and rscn.bof) then
		classname = rscn("classname")
	end if
	set rscn = nothing
	getClassName = classname
End Function
'取地区名
Function getAreaName(id)
	sqlcn = "select area from area where id = "&id
	set rscn = conn.execute(sqlcn)
	if not (rscn.eof and rscn.bof) then
		areaname = rscn("area")
	end if
	set rscn = nothing
	getAreaName = areaname
End Function

'取热门相关信息
Function getHotList(id)
	if id = 0 then
		'sqlhot = "select title,path from info where datediff('d',pubdate,now())<30 and flag=true order by hots desc"
		sqlhot = "select title,path from info where datediff('d',pubdate,now())<30 order by hots desc"
	else
		'sqlhot = "select title,path from info where classid="&id&" and datediff('d',pubdate,now())<30 and flag=true order by hots desc"
		sqlhot = "select title,path from info where classid="&id&" and datediff('d',pubdate,now())<30 order by hots desc"
	end if
	set rshot = server.CreateObject("adodb.recordset")
	rshot.open sqlhot,conn,1,1
	if not (rshot.eof and rshot.bof) then
		n = 16
		if n > rshot.recordCount then n=rshot.recordCount   
		for i = 1 to n
		rshot.Move i
  if rshot.eof then exit for
			title = rshot("title")
			str = str & "<li><a href="""&sitepath&htmlFolder&rshot("path")&""" title="""&title&""">"&LeftStr(title,24)&"</a></li>"
		rshot.Move - i
		next
	else
		str = "<li>暂无相关信息！</li>"
	end if
	rshot.close
	set rshot = nothing
	getHotList = str
End Function
'取相关信息
Function getOtherList(cid,aid,iid)
	'sqlOther = "select title,path from info where id <> "&iid&" and classid="&cid&" and areaid = "&aid&" and flag = true order by id desc"
	sqlOther = "select title,path from info where id <> "&iid&" and classid="&cid&" and areaid = "&aid&" order by id desc"
	set rsOther = server.CreateObject("adodb.recordset")
	rsOther.open sqlOther,conn,1,1
	if not (rsOther.eof and rsOther.bof) then
		n = 16
		if n > rsOther.recordCount then n=rsOther.recordCount   
		for i = 1 to n
		rsOther.Move i
  if rsOther.eof then exit for
		title = rsOther("title")
			
			str = str & "<li><a href="""&sitepath&htmlFolder&rsOther("path")&""" title="""&title&""">"&LeftStr(title,24)&"</a></li>"
		rsOther.Move - i
		next
	else
		str = "<li>暂无相关信息！</li>"
	End if
	rsOther.close
	set rsOther = nothing
	getOtherList = str
End Function
'修改静态路径
Sub UpdatePath(id,HtmlPath)
	sqlu = "update info set Path = '"&HtmlPath&"' where id = "&id
	conn.execute(sqlu)
End Sub

'///////////////////////后台信息操作函数////////////////

'/////////////-------- 生成首页 --------//////////////////
dim showinfo,areanav,classnav,list
Sub CreatIndex(tempPath,indexpath)
	meta = "<meta name=""robots"" content=""all"" /><meta name=""author"" content="""&authorname&""" /><meta name=""contact"" content="""&authorcontact&""" /><meta name=""Description"" content="""&description&""" /><meta name=""Keywords"" content="""&keywords&""" />"
	areanav = getArea(0,"")
	classnav = getClass(0)
	hotlist = getHotList(0)
	'///////////////////-------取信息列表
	sqlc = "select id,classname from class"
	set rsc = server.CreateObject("adodb.recordset")
	rsc.open sqlc,conn,1,1
	if not (rsc.eof and rsc.bof) then
		do while not rsc.eof
			cid = rsc("id")
			classname = rsc("classname")
			list = list & "<div class=""list""><h3><span><a href="""&sitepath&"class/?cid="&cid&""">更多&raquo;</a></span>"&classname&"</h3><ul>"
		'人民东路杨家山一品东庭[两室/80㎡-900元/月]芙蓉区2008-6-1 
			'sql = "select id,title,room,area,price,pricetype,areaid,pubdate,path from info where flag = true and classid = "&cid&" order by pubdate desc"
			sql = "select id,title,room,area,price,pricetype,areaid,pubdate,path from info where classid = "&cid&" order by pubdate desc"
			set rs = server.CreateObject("adodb.recordset")
			rs.open sql,conn,1,1
			if not (rs.eof and rs.bof) then
				n = 10
    w = 1
				if n > rs.recordCount then n=rs.recordCount   
				for i = 0 to n
				rs.Move i
					infoid = rs("id")
					title = rs("title")
					room = rs("room")
					area = rs("area")
					price = rs("price")
					if price = 0 then
						price = "面议"
					end if
					pricetype = rs("pricetype")
					areaid = rs("areaid")
					pubdate = rs("pubdate")
					path = rs("path")
					areaprice = room&"室"
					if area <> 0 then
						areaprice = areaprice & "/" & area & "㎡"
					end if
					areaprice = areaprice & "-"&price&pricetype
					areaname = getAreaName(areaid)
					pubdate = year(pubdate)&"-"&month(pubdate)&"-"&day(pubdate)
					if path = "" or isnull(path) then
						fileName = year(pubdate)&month(pubdate)&day(pubdate)&infoid&".html"
						path = right(year(pubdate),2)&month(pubdate)&day(pubdate)&"/"&fileName
						Call UpdatePath(infoid,path)
					end if
					list = list & "<li"
					if w mod 2 = 0 then
						list = list & " class=""bg1"""
					end if
					list = list & "><a href="""&sitepath&HtmlFolder&path&""" title="""&title&""">"&LeftStr(title,40)&"</a><span class=""area-price"">["&areaprice&"]</span><span class=""area"">"&areaname&"</span><span class=""date"">"&pubdate&"</span></li>"
     w = w +1
				rs.Move - i
				next
			else
				list = list & "<li>暂无此类信息</li>"
			end if
		'--------信息循环
		list = list & "</ul></div>"
		rsc.movenext
		loop
	end if
	rs.close
	set rs = nothing
	rsc.close
	set rsc = nothing
	areanav = getArea(0,"")
	classnav = getClass(0)
	hotlist = getHotList(0)
	'///////////////-----取信息列表结束 生成开始-----/////////////
	UrlTxt = tempPath
	UrlTxt = server.MapPath(UrlTxt)
	NewFile=NewRead(UrlTxt,"utf-8")
	NewFile = replace(NewFile,"<#meta#>",meta)
	NewFile = replace(NewFile,"<#sitepath#>",sitepath)
	'NewFile = replace(NewFile,"<#sitename#>",sitename)
	NewFile = replace(NewFile,"<#sitetitle#>",IndexTitle)
	NewFile = replace(NewFile,"<#sitename#>",sitename)
	NewFile = replace(NewFile,"<#classnav#>",classnav)
	NewFile = replace(NewFile,"<#areanav#>",areanav)
	NewFile = replace(NewFile,"<#list#>",list)
	NewFile = replace(NewFile,"<#hotlist#>",hotlist)
	NewFile = replace(NewFile,"<#links#>",Links)
	NewFile = replace(NewFile,"<#services#>",services)
	'创建文件目录
	Folder = indexpath
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	If Not fso.FolderExists(Server.MapPath(Folder)) Then fso.CreateFolder(Server.MapPath(Folder))
	Set fso = Nothing
	'结束
	file2 = Folder&"index.html"
	call Write2File(server.Mappath(file2),NewFile,"utf-8")
	'call ShowMsg("生成首页成功！","creat.asp")
End Sub

'/////////////-------- 生成全部 --------//////////////////
Sub CreatAll()
	'组件
	UrlTxt = "../temp/ad.html"
	UrlTxt = server.MapPath(UrlTxt)
	NewFile = NewRead(UrlTxt,"utf-8")
	'////////////////////------循环读取数据------/////////////////
	set rs = server.CreateObject("adodb.recordset")
	'sql = "select * from info where flag=true"
	sql = "select * from info order by id desc"
	rs.open sql,conn,1,1
	if (rs.eof and rs.bof) then
		Call ShowMsg("没有任何信息，不能生成！","back")
	else
		'分页
	dim currentpage
	maxperpage=20 '每次生成条数
	rs.pagesize=maxperpage
	currentpage=page
	if currentpage="" then
		currentpage=1
	elseif currentpage<1 then
		currentpage=1
	else
		currentpage=clng(currentpage)
		if currentpage > rs.pagecount then
			currentpage=rs.pagecount
			
		end if
	end if
	
	if not isnumeric(currentpage) then
		currentpage=1
	end if
	dim totalput,n
		totalput=rs.recordcount
	if totalput mod maxperpage=0 then
		n=totalput\maxperpage
	else
		n=totalput\maxperpage+1
	end if
	if n=0 then
		n=1
	end if
	rs.move(currentpage-1)*maxperpage
	i = 0
	infostr = ""
	do while i< maxperpage and not rs.eof
		Html = ""
		Html = NewFile
		summary = ""
		contact = ""
		'id,title,areaid,pubdate,price,pricetype,room,area,classid,region,info,username,tel,qq,email
		infoid = rs("id")
		title = rs("title")
		areaid = rs("areaid")
		agency = rs("agency")
		pubdate = rs("pubdate")
		price = rs("price")
		pricetype = rs("pricetype")
		room = rs("room")
		area = rs("area")
		classid = rs("classid")
		region = rs("region")
		info = rs("info")
		thisPageDescription = LeftStr(ClearHTML(info),200)
		username = rs("username")
		tel = rs("tel")
		qq = rs("qq")
		email = rs("email")
		path = rs("path")
		if path = "" or isnull(path) then
			fileName = year(pubdate)&month(pubdate)&day(pubdate)&infoid&".html"
			path = right(year(pubdate),2)&month(pubdate)&day(pubdate)&"/"&fileName
			Call UpdatePath(infoid,path)
		end if
		areaname = getAreaName(areaid)
		'summary
		if price <> "" then price = "价格："&price&pricetype&"<br />" else price = "价格：面议<br />"
		if room <> "" then room = "居室："&room&"室<br />"
		if area <> "" then area = "面积："&area&"㎡<br />"
		if agency = true then agency = "我是中介<br />" else agency = ""
		if region <> "" then region = "具体位置："&region
		summary = price&room&area&agency&region
		'contact
		if username <> "" then username = "<strong>联系人：</strong>"&username&"<br />" else username = "<strong>联系人：</strong>无名大侠<br />"
		if tel <> "" then tel = "<strong>手机/电话：</strong>"&tel&"<br />" else tel = "<strong>手机/电话：</strong>太懒了，电话都不留一个。<br />"
		if qq <> "" then qq = "<strong>QQ：</strong>"&qq&"<br />" else qq = ""
		if email <> "" then email = "<strong>E-MAIL：</strong>"&email else email = ""
		contact = username&tel&qq&email
		meta = "<meta name=""robots"" content=""all"" /><meta name=""author"" content="""&authorname&""" /><meta name=""contact"" content="""&authorcontact&""" /><meta name=""Description"" content="""&thisPageDescription&""" /><meta name=""Keywords"" content="""&title&""" />"
		areanav = getArea(0,"")
		classnav = getClass(classid)
		'otherlist = getOtherList(classid,areaid,infoid)
		
		'//////////生成
		HTML = replace(HTML,"<#meta#>",meta)
		HTML = replace(HTML,"<#sitepath#>",sitepath)
		HTML = replace(HTML,"<#sitename#>",sitename)
		HTML = replace(HTML,"<#classnav#>",classnav)
		HTML = replace(HTML,"<#areanav#>",areanav)
		HTML = replace(HTML,"<#infotitle#>",title)
		HTML = replace(HTML,"<#infoid#>",infoid)
		HTML = replace(HTML,"<#classid#>",classid)
		HTML = replace(HTML,"<#areaid#>",areaid)
		HTML = replace(HTML,"<#inarea#>",areaname)
		HTML = replace(HTML,"<#pubdate#>",pubdate)
		HTML = replace(HTML,"<#summary#>",summary)
		HTML = replace(HTML,"<#contact#>",contact)
		HTML = replace(HTML,"<#detail#>",info)
		'HTML = replace(HTML,"<#otherlist#>",otherlist)
		
		'创建文件目录
		Folder = "../"&HtmlFolder&path
		Set fso = Server.CreateObject("Scripting.FileSystemObject")
		tArr = Split(Folder, "/")
		tStr = tArr(0)
		For k = 1 To UBound(tArr) - 1
			tStr = tStr & "/" & tArr(k)
			'Response.Write(tStr & "<p>")
			If Not fso.FolderExists(Server.MapPath(tStr)) Then fso.CreateFolder(Server.MapPath(tStr))
		Next
		Set fso = Nothing
		'response.Write(file2)
		'response.End()
		call Write2File(server.Mappath(Folder),HTML,"utf-8")
		
		infostr = infostr & title & "<br />"
	i=i+1      
	rs.movenext
	loop
	end if
	rs.close
	set rs = nothing
	if currentpage < n then
		response.Write("共需生成"&n&"批，当前第"&currentpage&"批。<br /><br />"&infostr&"<br />")
		Response.Write("<script>window.setTimeout('getUrl()',1000);function getUrl(){window.location='?creat=all&amp;page="&currentpage+1&"';};</script>")
	elseif currentpage = n then
		call ShowMsg("生成全部结束！","creat.asp")
	end if
End Sub
'审核所选
Sub getAudit(id)
	sqlAudit = "update info set flag = true where id = "&cint(id)
	conn.execute(sqlAudit)
End Sub
'生成所选
Sub getCreat(id)
	set rs = server.CreateObject("adodb.recordset")
	sql = "select * from info where id = "&cint(id)
	rs.open sql,conn,1,1
	if not (rs.eof and rs.bof) then
		Html = ""
		Html = NewFile
		summary = ""
		contact = ""
		infoid = rs("id")
		title = rs("title")
		areaid = rs("areaid")
		agency = rs("agency")
		pubdate = rs("pubdate")
		price = rs("price")
		vcode = rs("vcode")
		pricetype = rs("pricetype")
		room = rs("room")
		area = rs("area")
		classid = rs("classid")
		region = rs("region")
		info = rs("info")
		thisPageDescription = LeftStr(ClearHTML(info),200)
		username = rs("username")
		tel = rs("tel")
		qq = rs("qq")
		email = rs("email")
		path = rs("path")
		if path = "" or isnull(path) then
			fileName = year(pubdate)&month(pubdate)&day(pubdate)&infoid&".html"
			path = right(year(pubdate),2)&month(pubdate)&day(pubdate)&"/"&fileName
			Call UpdatePath(infoid,path)
		end if
		'if email <> "" then
			'if IsValidEmail(email) = true then
				'if username = "" then username = "亲爱的朋友"
					'ipath = "http://www.cszufang.cn/"&HtmlFolder&path
					'spath = "http://www.cszufang.cn/self-service/?id="&infoid&"&vcode="&vcode
				'Call send(email,username,ipath,spath)
			'end if
		'end if

		areaname = getAreaName(areaid)
		'summary
		'response.write(price = 0)
		'response.end
		if price <> "" And price <> 0 then price = "价格："&price&pricetype&"<br />" Else price = "价格：面议<br />"
		if room <> "" then room = "居室："&room&"室<br />"
		if area <> "" then area = "面积："&area&"㎡<br />"
		if agency = true then agency = "我是中介<br />" else agency = ""
		if region <> "" then region = "具体位置："&region
		summary = price&room&area&agency&region
		'contact
		if username <> "" then username = "<strong>联系人：</strong>"&username&"<br />" else username = "<strong>联系人：</strong>无名大侠<br />"
		if tel <> "" then tel = "<strong>手机/电话：</strong>"&tel&"<br />" else tel = "<strong>手机/电话：</strong>太懒了，电话都不留一个。<br />"
		if qq <> "" then qq = "<strong>QQ：</strong>"&qq&"<br />" else qq = ""
		if email <> "" then email = "<strong>E-MAIL：</strong>"&email else email = ""
		contact = username&tel&qq&email
		meta = "<meta name=""robots"" content=""all"" /><meta name=""author"" content="""&authorname&""" /><meta name=""contact"" content="""&authorcontact&""" /><meta name=""Description"" content="""&thisPageDescription&""" /><meta name=""Keywords"" content="""&title&""" />"
		areanav = getArea(0,"")
		classnav = getClass(classid)
		'otherlist = getOtherList(classid,areaid,infoid)
		
		'//////////生成
		HTML = replace(HTML,"<#meta#>",meta)
		HTML = replace(HTML,"<#sitepath#>",sitepath)
		HTML = replace(HTML,"<#sitename#>",sitename)
		HTML = replace(HTML,"<#classnav#>",classnav)
		HTML = replace(HTML,"<#areanav#>",areanav)
		HTML = replace(HTML,"<#infotitle#>",title)
		HTML = replace(HTML,"<#infoid#>",infoid)
		HTML = replace(HTML,"<#classid#>",classid)
		HTML = replace(HTML,"<#areaid#>",areaid)
		HTML = replace(HTML,"<#inarea#>",areaname)
		HTML = replace(HTML,"<#pubdate#>",pubdate)
		HTML = replace(HTML,"<#summary#>",summary)
		HTML = replace(HTML,"<#contact#>",contact)
		HTML = replace(HTML,"<#detail#>",info)
		'HTML = replace(HTML,"<#otherlist#>",otherlist)
		'创建文件目录
		Folder = "../"&HtmlFolder&path
		Set fso = Server.CreateObject("Scripting.FileSystemObject")
		tArr = Split(Folder, "/")
		tStr = tArr(0)
		For i = 1 To UBound(tArr) - 1
			tStr = tStr & "/" & tArr(i)
			If Not fso.FolderExists(Server.MapPath(tStr)) Then fso.CreateFolder(Server.MapPath(tStr))
		Next
		Set fso = Nothing
		call Write2File(server.Mappath(Folder),HTML,"utf-8")
	end if
	rs.close
	set rs = nothing
End Sub
'删除所选
Sub getDel(id)
	sql = "select path from info where id="&cint(id)
	set rsDel = conn.execute(sql)
	If Not rsDel.eof Then
		Path = rsDel("Path")
	Else
		Call ShowMsg("您没有该信息编辑权限！\n或者该信息不存在！","back")
	End If
	set rs = nothing
	if path <> "" or not isnull(path) then
		Set fs = Server.CreateObject("Scripting.FileSystemObject")
			infopath = server.MapPath(SitePath&HtmlFolder&Path)
			if fs.FileExists(infopath) then	
				fs.deleteFile(InfoPath)
			end if
		Set fs = Nothing
	end if
	sqlD = "delete * from Info where id="&cint(id)
	conn.execute(sqlD)
End Sub
'检测是否重复数据
Sub isRepeat(title,tel)
	sqlRepeat = "select id from info where title='"&title&"' and tel = '"&tel&"'"
	Set rsRepeat = server.CreateObject("adodb.recordset")
	rsRepeat.open sqlRepeat,conn,1,1
	If Not rsRepeat.eof Then
		Call ShowMsg("请不要重复发布相同信息！","back")
	End If
	rsRepeat.close
	Set rsRepeat = nothing
End Sub
'JMAIL邮件发送
sub send(tomail,toname,infopath,selfpath)
if mailConfig = "Yes" then
	dim JMail
	set JMail=server.CreateObject("Jmail.message")
	JMail.Silent=true
	JMail.Charset = "utf-8"
	JMail.FromName = SiteName
	JMail.from = mailserverloginname
	JMail.AddRecipient tomail,toname
	JMail.Subject = "您在长沙租房网发布的信息已通过审核！"
	'jmail.Body=mailbody & vbcrlf & vbcrlf & mailfoot
	Jmail.HtmlBody = "<div style=""width:80%;margin:0 auto;border:1px solid #090;border-bottom-width:3px;font:normal 14px/24px arial;""><h1 style=""margin:0;padding:0 6px;font:700 1.5em/150% microsoft yahei;color:#fff;background-color:#090;"">长沙租房网 - <em>www.<span style=""color:#ff0;"">cs</span>zufang.com</em></h1><dl style=""padding:10px;margin:0;""><dt>亲爱的朋友：</dt><dd>您在<a href=""http://www.cszufang.com/"" target=""_blank"">长沙租房网</a>发布的房屋信息已通过审核！<br />您的信息地址：<a href="""&infopath&""" target=""_blank"">"&infopath&"</a><br />本站将提供一个用户自助管理的链接如下：<br /><a href="""&selfpath&""" target=""_blank"">"&selfpath&"</a><br />您可以通过该链接对该信息进行编辑、删除操作！<br />如果您还有什么不明白的请加客服QQ:973927。<br />非常感谢阁下对本站的信任与支持！</dd><dt style=""border-top:1px solid #ccc;color:#999;margin-top:10px;font-size:12px;"">By&nbsp;长沙租房网&nbsp;"&now()&"</dt></dl></div>"

	JMail.MailServerUserName = mailserverloginname
	JMail.MailServerPassWord = mailserverloginpass
	JMail.MailDomain = mailuserdomain
	sendok=JMail.send(mailserver)
	set Jmail = Nothing
	response.write("<br>ok")
end if
end sub
'call send("utf-8","973927@qq.com","龙翔")
'验证码
Function getCode(v)
	a = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","@","!","$","-","1","2","3","4","5","6","7","8","9","0")
	dim num 
	num = ""
	Randomize
	for i = 1 to v
		num = num & a(Int((65) * Rnd + 0))
	next
	getCode = num
End Function
%>